import threading


class MilvusParam(object):
    # 梁杰的测试用例，user表
    _userTableParam = None
    # 船舶法规，content_embedding_db表
    _boatNormTableParam = None
    _lock = threading.Lock()

    def __init__(self):
        self.collection_name = 'user'
        self.anns_field = "embeddings"
        self.param = {
            "metric_type": "L2",
            "params": {"nprobe": 10}
        }
        self.limit = 10
        self.expr = None
        self.partition_names = None
        self.output_fields = ["id"]
        self.timeout = None
        self.round_decimal = -1

    @staticmethod
    def getUserParam():
        # DCL双锁检查
        if MilvusParam._userTableParam is None:
            with MilvusParam._lock:
                if MilvusParam._userTableParam is None:
                    MilvusParam._userTableParam = MilvusParam()
                    MilvusParam._userTableParam.collection_name = "user"
                    MilvusParam._userTableParam.anns_field = "embeddings"
                    MilvusParam._userTableParam.output_fields = ["name", "desc"]
        return MilvusParam._userTableParam

    @staticmethod
    def getBoatNormParam():
        # DCL双锁检查
        if MilvusParam._boatNormTableParam is None:
            with MilvusParam._lock:
                if MilvusParam._boatNormTableParam is None:
                    MilvusParam._boatNormTableParam = MilvusParam()
                    MilvusParam._boatNormTableParam.collection_name = "content_embedding_db"
                    MilvusParam._boatNormTableParam.anns_field = "embeddings"
                    MilvusParam._boatNormTableParam.output_fields = ["file_name", "content_code", "content"]
        return MilvusParam._boatNormTableParam

    @staticmethod
    def getXXParam():
        pass
